import javax.swing.*;
import java.util.*;

class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode() {}
    TreeNode(int val) { this.val = val; }
    TreeNode(int val, TreeNode left, TreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }
}
public class project {
    public int minSteps(String s, String t) {
        int[] arr=new int[26];
        for(char ch:s.toCharArray()){
            arr[ch-'a']++;
        }
        for(char ch:t.toCharArray()){
            arr[ch-'a']--;
        }
        int ret=0;
        for(int value:arr){
            ret+=Math.abs(value);
        }
        return ret;
    }






















    public int[] restoreArray(int[][] adjacentPairs) {
        Map<Integer,List<Integer>> map=new HashMap<>();
        for(int[] arr:adjacentPairs){
            map.putIfAbsent(arr[0],new ArrayList<>());
            map.putIfAbsent(arr[1],new ArrayList<>());
            map.get(arr[0]).add(arr[1]);
            map.get(arr[1]).add(arr[0]);
        }
        int len=adjacentPairs.length+1;
        int[] ret=new int[len];
        for(Map.Entry<Integer,List<Integer>> entry:map.entrySet()){
            if(entry.getValue().size()==1){
                ret[0]=entry.getKey();
                break;
            }
        }
        ret[1]=map.get(ret[0]).get(0);
        for(int i=2;i<len;i++){
            List<Integer> list=map.get(ret[i-1]);
            ret[i]=ret[i-2]==list.get(0)?list.get(1):list.get(0);
        }
        return ret;
    }



















    public TreeNode createBinaryTree(int[][] descriptions) {
        Map<Integer,TreeNode> map=new HashMap<>();
        Set<Integer> set=new HashSet<>();
        for(int[] arr:descriptions){
            TreeNode prev=map.get(arr[0]);
            TreeNode node=map.get(arr[1]);
            if(prev==null){
                prev=new TreeNode(arr[0]);
                map.put(arr[0],prev);
            }
            if(node==null){
                node=new TreeNode(arr[1]);
                map.put(arr[1],node);
            }
            set.add(arr[1]);
            if(arr[2]==1){
                prev.left=node;
            }else{
                prev.right=node;
            }
        }
        TreeNode root=null;
        for(int key:map.keySet()){
            if(!set.contains(key)){
                root=map.get(key);
                break;
            }
        }
        return root;
    }

























    public List<String> cellsInRange(String s) {
        List<String> list=new ArrayList<>();
        String[] str=s.split(":");
        char left=str[0].charAt(0);
        char right=str[1].charAt(0);
        int up=Integer.parseInt(str[0].charAt(1)+"");
        int lower=Integer.parseInt(str[1].charAt(1)+"");
        for(char ch=left;ch<=right;ch++){
            for(int i=up;i<=lower;i++){
                StringBuilder sb=new StringBuilder();
                sb.append(ch).append(i);
                list.add(sb.toString());
            }
        }
        return list;
    }

















    public String convertToBase7(int num) {
        boolean bool=num<0;
        if(num==0){
            return "0";
        }
        StringBuffer sb=new StringBuffer();
        num=Math.abs(num);
        while (num>0){
            sb.append(num%7);
            num/=7;
        }
        if(bool){
           sb.append("-");
        }
        return sb.reverse().toString();
    }
}
